package cashin



import grails.test.mixin.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(Receipt)
class ReceiptTests {



    void testTicketTotal() {

       Item i1=new Item(sellingPrice: 100,vat:21,providerPrice: 50,description: 'aaa' )
        print i1.sellingPrice
       ReceiptLine rl1=new ReceiptLine()
        rl1.item = i1

       ReceiptLine rl2=new ReceiptLine(item: new Item(sellingPrice: 200,vat:21,providerPrice: 100,description: 'aaa'))

       Receipt r=new Receipt(ticketLines: [rl1,rl2])

       assert 300==r.total

         rl1=new ReceiptLine(item: new Item(sellingPrice: 100,vat:21,providerPrice: 50,description: 'aaa'),discount: 0)
         rl2=new ReceiptLine(item: new Item(sellingPrice: 200,vat:21,providerPrice: 100,description: 'aaa'),discount: 50)

         r=new Receipt(ticketLines: [rl1,rl2])

        assert 200==r.total
    }
}
